package com.superm.service.impl;

import com.superm.entity.*;
import com.superm.mappers.GodownEntryMapper;
import com.superm.service.GodownEntryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class GodownEntryServiceImpl implements GodownEntryService {

    @Autowired
    private GodownEntryMapper godownEntryMapper;
    /**
     *  实现模糊查询采购入库单
     * @param
     * @return
     */
    @Override
    public Map<String, Object> likeGodownEntry(GodownEntryPoJo godownEntryPoJo,Integer pageNo,Integer pageSize) {
        //替换值
        GodownEntry godownEntry = new GodownEntry();
        BeanUtils.copyProperties(godownEntryPoJo,godownEntry);
        //申请单
        godownEntry.setPurchase(new Purchase(godownEntryPoJo.getPurchase(),new RepostoryType(godownEntryPoJo.getRepostoryId())));
        //经办人
        godownEntry.setEmp(new Emp(godownEntryPoJo.getEName()));
        Map<String,Object> map = new HashMap<String,Object>();
        List<GodownEntry> godownEntries =  godownEntryMapper.likeMationInfo(godownEntry,(pageNo-1)*pageSize,pageSize);
        map.put("code",0);
        map.put("count",godownEntryMapper.count(godownEntry));
        map.put("data",godownEntries);
        return map;
    }
}
